/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       shroud_removers.h

	$Header: /game/shroud_removers.h $

	$NoKeywords: $

 ************************************************************************/

#ifndef SHROUD_REMOVERS_H_INCLUDED
#define SHROUD_REMOVERS_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#pragma warning( disable: 4786 )

#include "army_ptr.h"
#include "bitset"
#include "idle_processor.h"
#include "adv_magi_eye.h"
#include "override_input_handler.h"
#include "player_color.h"
#include "stationary_adventure_object.h"


// -----------------------------------------------------------------
// shroud remover base class : 
//  NOTE the reason why activate_tigger calls do_logic to actually implement the 
//  logic is becuase the replay/multiplay events also need to execute the logic of the without
//  poping up a dialog box.
// -----------------------------------------------------------------
class t_shroud_remover : public t_stationary_adventure_object
{
public:
	typedef std::bitset<k_active_player_color_count> t_visited_bits;


	t_shroud_remover( t_stationary_adventure_object const& source );
	virtual float			ai_value( t_adventure_ai const& ai, t_creature_array const& army, int move_cost ) const;	
	virtual void			activate_trigger( t_army* army, t_adv_map_point const& point, 
								              t_direction direction, t_adventure_frame* frame );
	virtual void			do_logic( t_army* army, t_adv_map_point const& point, 
								              t_direction direction, t_adventure_frame* frame);
	virtual void			show_dialog( bool visited , t_adv_map_point const& point );
	virtual int				get_version() const;
	virtual bool			get_visited( size_t team_num );
	virtual void			set_visited( size_t team_num );
	virtual bool			read( std::streambuf&							stream, 
										t_qualified_adv_object_type const&	type,
										int									version );
	virtual bool			write( std::streambuf& stream ) const;	

private:
	t_visited_bits			m_visited;	// Contains a bit set for each team that can visit the object
};

// -----------------------------------------------------------------
// cartographer
// -----------------------------------------------------------------
class t_cartographer : public t_shroud_remover
{
public:
	t_cartographer( t_stationary_adventure_object const& source );
	virtual void	activate_trigger( t_army* army, t_adv_map_point const& point, 
		                                   t_direction direction, t_adventure_frame* frame );
	virtual void	do_logic( t_army* army, t_adv_map_point const& point, 
								           t_direction direction, t_adventure_frame* frame);
	virtual void	show_dialog( bool visited , t_adv_map_point const& point);
};

// -----------------------------------------------------------------
// hut of the magi
// -----------------------------------------------------------------
class t_magi_hut : public t_shroud_remover, public t_idle_processor
{
public:
	t_magi_hut( t_stationary_adventure_object const& source );
	virtual void	activate_trigger( t_army* army, t_adv_map_point const& point, 
		                                   t_direction direction, t_adventure_frame* frame );
	virtual void	do_logic( t_army* army, t_adv_map_point const& point, 
								           t_direction direction, t_adventure_frame* frame);
	virtual void	show_dialog( bool visited , t_adv_map_point const& point);

	virtual void	on_idle();

protected:
	void			cancel();
	bool			visit_next_eye( t_tile_visibility visibility );

	typedef t_owned_ptr<t_override_input> t_override_input_ptr;

	int									m_view_team;
	t_adv_magi_eye_list::const_iterator m_curr_eye;
	bool								m_curr_eye_live;
	bool								m_first_time;
	t_override_input_ptr				m_input_handler;
	int									m_original_view_level;
	t_screen_point						m_original_view_pos;

};

// -----------------------------------------------------------------
// tower
// contains redwood tree, tower, and ice spire types
// -----------------------------------------------------------------
class t_tower : public t_shroud_remover
{
public:
	t_tower( t_stationary_adventure_object const& source );
	virtual void	activate_trigger( t_army* army, t_adv_map_point const& point, 
		                                   t_direction direction, t_adventure_frame* frame );
	virtual void	do_logic( t_army* army, t_adv_map_point const& point, 
								           t_direction direction, t_adventure_frame* frame);
	virtual void	show_dialog( bool visited , t_adv_map_point const& point);
};


// -----------------------------------------------------------------
// -----------------------------------------------------------------
// -----------------------------------------------------------------
// -----------------------------------------------------------------

// -----------------------------------------------------------------
// inline t_shroud_remover member functions
// overloaded get_version for backward compatibility
// -----------------------------------------------------------------
inline int	t_shroud_remover::get_version() const
{
	return 1;
}

inline bool	t_shroud_remover::get_visited( size_t team_num )
{
	return m_visited.test(team_num);
}

inline void	t_shroud_remover::set_visited( size_t team_num )
{
	m_visited.set(team_num);
}


#endif // SHROUD_REMOVERS_H_INCLUDED
